package com.edu.web.controller.info;

import com.edu.system.domain.TClass;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.edu.common.annotation.Log;
import com.edu.common.core.controller.BaseController;
import com.edu.common.core.domain.AjaxResult;
import com.edu.common.enums.BusinessType;
import com.edu.system.domain.TClassGroup;
import com.edu.system.service.ITClassGroupService;
import com.edu.common.utils.poi.ExcelUtil;
import com.edu.common.core.page.TableDataInfo;

/**
 * 班牌编组Controller
 * 
 * @author xxxx
 * @date 2023-12-27
 */
@RestController
@RequestMapping("/system/group")
public class TClassGroupController extends BaseController
{
    @Autowired
    private ITClassGroupService tClassGroupService;

    /**
     * 查询班牌编组列表
     */
    @PreAuthorize("@ss.hasPermi('system:group:list')")
    @GetMapping("/list")
    public TableDataInfo list(TClassGroup tClassGroup)
    {
        startPage();
        List<TClassGroup> list = tClassGroupService.showTClassGroupList(tClassGroup);
        return getDataTable(list);
    }

    /**
     * 导出班牌编组列表
     */
    @PreAuthorize("@ss.hasPermi('system:group:export')")
    @Log(title = "班牌编组", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TClassGroup tClassGroup)
    {
        List<TClassGroup> list = tClassGroupService.showTClassGroupList(tClassGroup);
        ExcelUtil<TClassGroup> util = new ExcelUtil<TClassGroup>(TClassGroup.class);
        util.exportExcel(response, list, "班牌编组数据");
    }

    /**
     * 获取班牌编组详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:group:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tClassGroupService.selectTClassGroupById(id));
    }

    /**
     * 新增班牌编组
     */
    @PreAuthorize("@ss.hasPermi('system:group:add')")
    @Log(title = "班牌编组", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TClassGroup tClassGroup)
    {
        return toAjax(tClassGroupService.insertTClassGroup(tClassGroup));
    }

    /**
     * 修改班牌编组
     */
    @PreAuthorize("@ss.hasPermi('system:group:edit')")
    @Log(title = "班牌编组", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TClassGroup tClassGroup)
    {
        return toAjax(tClassGroupService.updateTClassGroup(tClassGroup));
    }

    /**
     * 删除班牌编组
     */
    @PreAuthorize("@ss.hasPermi('system:group:remove')")
    @Log(title = "班牌编组", businessType = BusinessType.DELETE)
	  @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tClassGroupService.deleteTClassGroupByIds(ids));
    }

    /**
     * 班级组总列表
     */
    @GetMapping("/info/allList")
    public AjaxResult allList() {
        List<TClassGroup> list = tClassGroupService.selectTClassGroupList(new TClassGroup());
        return AjaxResult.success(list);
    }
}
